import pymysql
from ..database import connect_to_database, close_database_connection


async def insertUserInfo(uUserName, uPassword):
    db, ssh_tunnel = connect_to_database()
    cursor = db.cursor(cursor=pymysql.cursors.DictCursor)
    sql = "INSERT INTO user (id, user_pass) VALUES (%s, %s)"
    try:
        cursor.execute(sql, (uUserName, uPassword))
        uploadSucceed = True
        db.commit()
    except Exception as e:
        print(e)
        uploadSucceed = False
        db.rollback()
    cursor.close()
    close_database_connection(db, ssh_tunnel)
    return uploadSucceed
